package cc.booku.owlbox.UnSearchPage;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import android.widget.Toast;

import com.czp.searchmlist.mSearchLayout;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import cc.booku.owlbox.ArtDesign.SystemUtil;
import cc.booku.owlbox.R;

public class SearchActivity extends AppCompatActivity {


    //测试搜索：http://localhost:2020/search.php?searchdata=
    private mSearchLayout SearchView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
//状态栏颜色
        SystemUtil.setStatusBarColor(this, Color.parseColor("#448aca"));
        SearchView = (mSearchLayout) findViewById(com.czp.searchmlist.R.id.msearchlayout);
        initData();
    }

    protected void initData() {
        //历史记录
        String shareData = "Caribbeancom,Tokyo Hot,上川星空,来栖ちゃこ,白河里奈,水谷心音,水咲ローラ,水城奈緒,波多野結衣";
        List<String> skills = Arrays.asList(shareData.split(","));

        //大家都在搜
        String shareHotData = "酒池肉林,梦见照歌,木村津名,口交,萝莉,制服,cos,heyzo";
        List<String> skillHots = Arrays.asList(shareHotData.split(","));

        SearchView.initData(skills, skillHots, new mSearchLayout.setSearchCallBackListener() {
            @Override
            public void Search(String str) {
                //进行或联网搜索
                //读取配置文件中的搜索接口

                try {

                    //刷新
                    Intent intent = new Intent();
                    Bundle bundle = new Bundle();
                    bundle.putString("SearchData", str);
                    intent.putExtras(bundle);
                    intent.setClass(SearchActivity.this, SearchListActivity.class);
                    startActivity(intent);

                } catch (Exception e) {

                    Toast.makeText(SearchActivity.this, "配置文件错误", Toast.LENGTH_SHORT).show();
//异常处理
                }


            }

            @Override
            public void Back() {
                finish();
            }

            @Override
            public void ClearOldData() {
                //清除历史搜索记录  更新记录原始数据
            }

            @Override
            public void SaveOldData(ArrayList<String> AlloldDataList) {
                //保存所有的搜索记录
            }
        });
    }


}
